package com.yazi.mxz.common.service;

import java.util.List;

import com.myframework.smhj.common.exception.MyException;
import com.myframework.smhj.hibernate.dao.Service;

import com.yazi.mxz.common.entity.beans.GoodsGift;
import com.yazi.mxz.common.entity.beans.GoodsPromote;
import com.yazi.mxz.common.entity.beans.GoodsPromoteId;
import com.yazi.mxz.common.entity.beans.Store;
import com.yazi.mxz.common.entity.enums.GoodsPromoteStatus;
import com.yazi.mxz.common.entity.enums.GoodsPromoteType;

/**
 * 商品促销信息Service
 * @author mo_yq5
 * @date 2014-11-27
 */
public interface GoodsPromoteService extends Service<GoodsPromote> {

	/**
	 * 结束已经到结束时间的商品促销
	 * 
	 */
	int endByTime(GoodsPromoteType type);
	
	/**
	 * 开始已经到开始时间的商品促销
	 * 
	 */
	int startByTime(GoodsPromoteType type);
	
	/**
	 * 获取最近一个要开始的商品促销
	 * @return
	 */
	GoodsPromote oneNextStart();
	
	/**
	 * 获取最近一个要结束的商品促销
	 * @return
	 */
	GoodsPromote oneNextEnd();
	
	/**
	 * 编辑商品促销
	 * @param store 店铺(游离对象)
	 * @param promote 促销(表单对象)
	 * @param gifts 赠送商品(s)(表单对象 )
	 * @return
	 */
	GoodsPromote addOrEditByStore(Store store, GoodsPromote promote, List<GoodsGift> gifts) throws MyException;
	
	/**
	 * 删除商品促销
	 * @param store 店铺(游离对象)
	 * @param id 促销ID
	 */
	void removeByStore(Store store, GoodsPromoteId id) throws MyException;
	
	/**
	 * 删除商品促销(批量)
	 * @param store 店铺(游离对象)
	 * @param ids 促销ID(s)
	 */
	void removeByStore(Store store, List<GoodsPromoteId> ids) throws MyException;
	
	/**
	 * 更新促销状态，只能进行取消和恢复两个操作
	 * @param store 店铺(游离对象)
	 * @param id 促销ID
	 * @param status 目标状态
	 */
	void editStatusByStore(Store store, GoodsPromoteId id, GoodsPromoteStatus status) throws MyException;
}
